package org.zjsru.user.mapper;

import org.zjsru.user.pojo.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;

public interface UserMapper {
    
    @Select("select * from tb_user where id = #{id}")
    User findById(@Param("id") Long id);
    
    @Select("select * from tb_user where username = #{username}")
    User findByUsername(@Param("username") String username);
    
    @Insert("insert into tb_user (username, password, email, phone, address, status, create_time, update_time) " +
            "values (#{username}, #{password}, #{email}, #{phone}, #{address}, #{status}, #{createTime}, #{updateTime})")
    int insert(User user);
    
    @Update("update tb_user set username = #{username}, email = #{email}, phone = #{phone}, " +
            "address = #{address}, update_time = #{updateTime} where id = #{id}")
    int update(User user);
}